{% extends 'layout.html' %}

{% block content %}
    <div class="row">
        <div class="col-sm-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">编辑用户信息</h3>

                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-chevron-up"></i>
                        </button>
                        <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i>
                        </button>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body">

                    <div class="col-sm-10">
                        <form method="post" id="user_form" class="form-horizontal" action="">
                            <div class="form-group">
                                <div class="col-sm-8">
                                    <input id="user_id" name="user_id" type="text" value="{{ user.id }}"
                                           style="display: none">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="name" class="col-sm-2 control-label">姓名<span
                                        class="text-red">*</span>：</label>
                                <div class="col-sm-8">
                                    <input id="name" name="name" placeholder="Name" type="text" class="form-control"
                                           value="{{ user.name }}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="password" class="col-sm-2 control-label">密码：</label>
                                <div class="col-sm-8">
                                    <input id="password" name="password" placeholder="Password" type="password"
                                           class="form-control">
                                    <span class="help-block m-b-none">
                                        登陆web的密码, 不修改请留空
                                    </span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="ssh_key_pwd" class="col-sm-2 control-label">SSH密钥：</label>
                                <div class="col-sm-8" style="border: none">
                                    <a value="" id="regen_ssh_key"
                                       class="form-control"> 重新生成</a>
                                    <span class="help-block m-b-none">
                                        重新生成密钥，需要重新下载并导入
                                    </span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="email" class="col-sm-2 control-label">Email<span
                                        class="text-red">*</span>：</label>
                                <div class="col-sm-8">
                                    <input id="email" name="email" type="email" placeholder="Email"
                                           class="form-control"
                                           value="{{ user.email }}">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button id="submit_button" class="btn btn-default" type="submit">确认修改</button>
                                    <button class="btn btn-white" type="reset">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>

                    <!-- /.row -->
                </div>
                <!-- ./box-body -->
            </div>
            <!-- /.box -->
        </div>
        <!-- /.col -->
    </div>
{% endblock %}

{% block self_footer_js %}
    <script>
        $('#user_form').validator({
            timely: 2,
            theme: "yellow_right_effect",
            fields: {
                "name": {
                    rule: "required",
                    tip: "姓名",
                    ok: "",
                    msg: {required: "必须填写"}
                },
                "email": {
                    rule: "required",
                    tip: "Email",
                    ok: "",
                    msg: {required: "必须填写"}
                }
            },
            valid: function (form) {
                form.submit();
            }
        });
    </script>
{% endblock %}